package com.springboot.service.aop;

/**
 * @Author: luobendexiaoqiang
 * @Date: 2020/8/1 16:16
 */

import com.springboot.service.condition.TaskFilterCondition;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Conditional;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

@Component
@Aspect
@Slf4j
@Conditional(TaskFilterCondition.class)
@Order(1)
@ConfigurationProperties(prefix = "scheduled")
public class FilterScheduledHandler {

    /**
     * 执行的定时器
     */
    private Map<String,List<String>> workJobs;


    @Pointcut("execution(public * com.springboot..*.*(..)) && @annotation(org.springframework.scheduling.annotation.Scheduled)")
    public void proxyAspect() {

    }

    @Around("proxyAspect()")
    public Object doInvoke(ProceedingJoinPoint joinPoint) {
        String className = joinPoint.getTarget().getClass().getName();
        String method =  joinPoint.getSignature().getName();
        log.info("定时任务开始被拦截order1");

        try {
             joinPoint.proceed();
        } catch (Throwable throwable) {
            throwable.printStackTrace();
        }
        log.info("定时任务结束被拦截order1");
        return null;
    }
}

